package com.evil.Servlet;

import com.evil.Bean.ShareBean;
import com.evil.DAO.ShareDAO;

import java.io.IOException;
import java.util.ArrayList;

/********************************************
 * 工程名：Web
 * 包名：${PACKAGE_NAME}
 * 时间：16-9-25 下午10:01
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：分享邀请Servlet
 ********************************************/
public class ShareServlet extends BaseServlet
{
    private String type;
    private String phone;
    private String imei;
    private String inviter_phone;

    @Override
    public void doPost() throws IOException
    {
        type = getParameter("type");
        phone = getParameter("phone");
        imei = getParameter("imei");
        inviter_phone = getParameter("inviter_phone");

        /*填写邀请码*/
        if (type.equals("getList"))
        {
            //Utils.sleep(5000);
            getAllList();
        }
        else if (type.equals("wirte"))
        {
            if (!phone.equals("") && !inviter_phone.equals(""))
                if (!phone.equals(inviter_phone))
                    wirtePhone();
                else
                    print("FAIL:请勿提交本机号码！");
        }
    }

    /**
     * 填写邀请码
     */
    private void wirtePhone()
    {
        ShareDAO dao = new ShareDAO();
        String re = dao.insert_inviter(phone, inviter_phone);
        print(re);
    }

    private void getAllList()
    {
        ShareDAO dao = new ShareDAO();
        print(dao.getAll_invitees(phone));
    }


}
